# coding: utf-8
{{>partial_header}}

import typing
import inspect
from datetime import date, datetime
from {{packageName}}.client_custom import ClientCustom
from {{packageName}}.configuration import Configuration
from {{packageName}}.api_client import ApiClient
from {{packageName}}.type_util import copy_signature
{{#with apiInfo}}
{{#each apis}}
from {{packageName}}.apis.tags.{{classVarName}} import {{classname}}
{{/each}}
{{/with}}

{{#each topLevelClientTypeImports}}
{{.}}
{{/each}}


class {{clientName}}(ClientCustom):

    def __init__(self, configuration: typing.Union[Configuration, None] = None, **kwargs):
        super().__init__(configuration, **kwargs)
        if (len(kwargs) > 0):
            configuration = Configuration(**kwargs)
        if (configuration is None):
            raise Exception("configuration is required")
        api_client = ApiClient(configuration)
        {{#with apiInfo}}
        {{#each apis}}
        {{! we need to add ": classname" for PyCharm to throw type hint / unexpected parameter errors }}
        self.{{> api_class_name}}: {{classname}} = {{classname}}(api_client)
        {{/each}}
        {{/with}}
{{#with apiInfo}}
{{#each apis}}
{{#each topLevelOperations}}

    @copy_signature({{classname}}.a{{operationId}})
    async def a{{vendorExtensions.x-konfig-top-level-operation}}(
    {{> endpoint_args async=true isOverload=false skipDeserialization="null" contentType="null" interface=true omitReturnType=true}}
        return await self.{{> api_class_name}}.a{{operationId}}(
            {{> endpoint_args_call_mapped_args async=true}}
        )

    @copy_signature({{classname}}.{{operationId}})
    def {{vendorExtensions.x-konfig-top-level-operation}}(
    {{> endpoint_args isOverload=false skipDeserialization="null" contentType="null" interface=true omitReturnType=true}}
        return self.{{> api_class_name}}.{{operationId}}(
            {{> endpoint_args_call_mapped_args}}
        )
{{/each}}
{{/each}}
{{/with}}
